#include <hikari.h>
#include<BulletPhysicsHComponent.h>

void BulletPhysicsHComponent::onSceneLoad(HikariContext*context, HObj*object){

}

void BulletPhysicsHComponent::onSceneUnload(HikariContext*context, HObj*object){

}

btVector3 vectorToBtVector(const vector3df&vector);
//{
//	return btVector3(vector.X, vector.Y, vector.Z);
//}

vector3df btVectorToVector(const btVector3&v);
//{
//	return vector3df(v.getX(), v.getY(), v.getZ());
//}



void BulletPhysicsHComponent::onRender(HikariContext*context, HObj*object){
	const btVector3&centerOfMass=rigidBody->getCenterOfMassPosition();
	vector3df position=btVectorToVector(centerOfMass)+offsetPos;
	object->getInternalNode()->setPosition(position);
	
	vector3df euler;
	const btQuaternion& tQuat = rigidBody->getOrientation();
	quaternion q(tQuat.getX(), tQuat.getY(), tQuat.getZ(), tQuat.getW());
	q.toEuler(euler);
	euler *= RADTODEG;
	object->getInternalNode()->setRotation(euler);
}